<?php

namespace App\Http\Controllers;

use App\Models\District;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

class DistrictController extends Controller
{
    //
    public function getlist(Request $request)
    {
        $model = District::query();
        // $province_adcode = $request->input('province_adcode');
        // if($province_adcode){
        //     $model->where('adcode',$province_adcode);
        // }
        $list = $model->select('adcode', 'name','center')->orderBy('adcode','asc')->get();
        
        return new ResourceCollection($list);
        //        $list = District::query()->pluck('name','adcode');
        //        $list = District::query()->pluck('name','adcode');
        //        foreach ($list as $item){
        //            echo $item->name.'<br>';
        //            echo $item->adcode.'<br>';
        //        }
        //        dump($list);
    }
}
